home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import re
- from checkbox.lib.cache import cache
- from checkbox.lib.conversion import string_to_type
- from checkbox.properties import Path
- from checkbox.registries.filename import FilenameRegistry
-
- class MeminfoRegistry(FilenameRegistry):
- '''Registry for memory information.
-
- Each item contained in this registry consists of the information
- in the /proc/meminfo file.
- '''
- filename = Path(default = '/proc/meminfo')
-
- def items(self):
- meminfo = { }
- for line in self.split('\n'):
- match = re.match('(.*):\\s+(.*)', line)
- if match:
- key = match.group(1)
- value = string_to_type(match.group(2))
- meminfo[key] = value
- continue
-
- meminfo_to_items = (('MemTotal', 'total'), ('SwapTotal', 'swap'))
- items = []
- for mkey, ikey in meminfo_to_items:
- value = meminfo[mkey]
- items.append((ikey, value))
-
- return items
-
- items = cache(items)
-
- factory = MeminfoRegistry
-